import 'dart:convert';

import 'package:azlistview/azlistview.dart';

class CityModel extends ISuspensionBean {
  String name;
  String? tagIndex;
  String? namePinyin;

  CityModel({
    required this.name,
    this.tagIndex,
    this.namePinyin,
  });

  CityModel.fromJson(Map<String, dynamic> json)
      : name = json['name'],
        tagIndex = json['tagIndex'],
        namePinyin = json['namePinyin'];

  Map<String, dynamic> toJson() => {'name': name, 'tagIndex': tagIndex, 'namePinyin': namePinyin};

  @override
  String getSuspensionTag() => tagIndex!;

  @override
  String toString() => json.encode(this);
}

class CityDataModel extends ISuspensionBean {
  String name;
  String? tagIndex;
  String? namePinyin;
  List<CityModel>? children;

  CityDataModel({required this.name, this.tagIndex, this.namePinyin, this.children});

  CityDataModel.fromJson(Map<String, dynamic> json)
      : name = json['name'],
        tagIndex = json['tagIndex'],
        namePinyin = json['namePinyin'],
        children = json['children'];

  Map<String, dynamic> toJson() =>
      {'name': name, 'tagIndex': tagIndex, 'namePinyin': namePinyin, 'children': children};

  @override
  String getSuspensionTag() {
    return name;
  }

  @override
  String toString() => json.encode(this);
}
